package com.cos.shop.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author: COS
 * @time: 2022/2/16 16:35
 * @description:
 */
public class DateUtils {
    /**
     *
     * @author: COS
     * @return:
     * @time: 2022/2/16 16:36
     * @description: 字符串转utilDate的方法
     */
    public static Date stringToDate(String date) {
        SimpleDateFormat sdm = new SimpleDateFormat("yyyy-MM-dd");
        try {
            return sdm.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     *
     * @author: COS
     * @return:
     * @time: 2022/2/16 16:38
     * @description: 日期转字符串
     */
    public static String dateToString(Date date){
        SimpleDateFormat sdm = new SimpleDateFormat("yyyy-MM-dd");
        return sdm.format(date);
    }
}
